﻿package mortal.game.view.guildNew.WareHourse
{
    import Message.Game.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import extend.language.*;
    import fl.data.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.common.global.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.pageSelect.*;
    import mortal.game.view.guild.otherpanel.*;
    import mortal.game.view.guild.util.*;
    import mortal.mvc.core.*;

    public class GuildNewWareHRight extends GSprite
    {
        protected var _tMemName:GTextFiled;
        protected var _tAtt:GTextFiled;
        protected var _tGood:GTextFiled;
        protected var _list:GTileList;
        protected var _sortUpBtn:GLoadedButton;
        protected var _pageSelecter:PageSelecter;
        protected var _confirmBtn:GButton;
        private var _pageTool:PageTool;

        public function GuildNewWareHRight()
        {
            this._pageTool = new PageTool([], 8);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._tMemName = UIFactory.gTextField("" + Language.getString(71643), 25, 38, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._tAtt = UIFactory.gTextField("" + Language.getString(71644), 115, 38, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._tGood = UIFactory.gTextField("" + Language.getString(71645), 217, 38, 100, 20, this, GlobalStyle.textFormatPutong.setColor(16777215));
            this._list = UIFactory.tileList(4, 56, 335, 392, this);
            this._list.direction = GBoxDirection.VERTICAL;
            this._list.verticalGap = 0;
            this._list.horizontalGap = 2;
            this._list.rowHeight = 49;
            this._list.columnWidth = 320;
            this._list.columnCount = 1;
            this._list.rowCount = 8;
            this._list.width = 335;
            this._list.setStyle("cellRenderer", GuildNewWareHCell);
            this._sortUpBtn = UIFactory.gLoadedButton(ImagesConst.ascendingSortBtn_upSkin, 169, 42, 11, 14, this);
            this._sortUpBtn.label = "";
            this._pageSelecter = UIFactory.pageSelecter(99, 449, this, PageSelecter.CompleteMode);
            this._pageSelecter.setbgStlye(ImagesConst.ComboBg, GlobalStyle.textFormatBai.center());
            this._pageSelecter.maxPage = 1;
            this._pageSelecter.pageTextBoxSize = 36;
            this._pageSelecter.configEventListener(Event.CHANGE, this.onPageChange);
            this._confirmBtn = UIFactory.gButton("" + Language.getString(71646), 245, 448, 65, 25, this);
            this._confirmBtn.configEventListener(MouseEvent.CLICK, this.onConfirmBtnClick);
            this._sortUpBtn.configEventListener(MouseEvent.CLICK, this.onSortUpBtnClick);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._tMemName = null;
            this._tAtt = null;
            this._tGood = null;
            this._list = null;
            this._sortUpBtn = null;
            this._pageSelecter = null;
            this._confirmBtn = null;
            super.disposeImpl(param1);
            return;
        }// end function

        public function update(param1:Object) : void
        {
            this.onInfoRes(param1);
            return;
        }// end function

        private function onPageChange(event:Event = null) : void
        {
            this._list.dataProvider = new DataProvider(this._pageTool.getByPageNo(this._pageSelecter.currentPage));
            this._list.drawNow();
            return;
        }// end function

        private function onConfirmBtnClick(event:MouseEvent) : void
        {
            var _loc_5:Array = null;
            var _loc_6:String = null;
            var _loc_2:* = GuildResourceRecordUitl.instance.notEnoughMap;
            if (_loc_2)
            {
                _loc_5 = [];
                for (_loc_6 in _loc_2)
                {
                    
                    _loc_5.push(int(_loc_6));
                }
                GuildResourceAllotTipPanel.instance.show();
                GuildResourceAllotTipPanel.instance.data = _loc_5;
                return;
            }
            var _loc_3:* = GuildResourceRecordUitl.instance.allPlayerItem;
            if (_loc_3.length <= 0)
            {
                MsgManager.showRollTipsMsg(Language.getString(71647));
                return;
            }
            var _loc_4:Object = {};
            _loc_4.oper = new EGuildWarehouseOper(EGuildWarehouseOper._EGuildWarehouseAllocation);
            _loc_4.item = _loc_3;
            _loc_4.oprMoney = null;
            Dispatcher.dispatchEvent(new DataEvent(EventName.Guild_wareHouse_oper, _loc_4));
            return;
        }// end function

        private function onSelectItemUpdata(event:DataEvent) : void
        {
            this.onPageChange();
            return;
        }// end function

        private function onSortUpBtnClick(event:MouseEvent = null) : void
        {
            this._pageTool.array.sortOn("contributionWeek", Array.NUMERIC | Array.DESCENDING);
            this.onPageChange();
            return;
        }// end function

        private function onInfoRes(param1:Object) : void
        {
            this._pageTool.array = param1 as Array;
            this._pageSelecter.maxPage = this._pageTool.pagesCount;
            this.onSortUpBtnClick();
            return;
        }// end function

        public function onallocationSuccess(param1:Object = null) : void
        {
            GuildResourceRecordUitl.instance.clean();
            this.onPageChange();
            return;
        }// end function

    }
}
